from building import *

cwd = GetCurrentDir()

objs = []

# add the general drivers.
src = Split('''
board.c
''')

# add gpio code
if GetDepend('RT_USING_PIN'):
    src += ['drv_gpio.c']

# add serial driver code
if  GetDepend('BSP_USING_UART0') or GetDepend('BSP_USING_UART1'):
    src += ['drv_uart.c']

# add spi driver code
if  GetDepend('BSP_USING_SPI0') or GetDepend('BSP_USING_SPI1'):
    src += ['drv_spi.c']

# add i2c driver code
if  GetDepend('BSP_USING_I2C0') or GetDepend('BSP_USING_I2C1'):
    src += ['drv_i2c.c']

# add spi flash driver code
if GetDepend('BSP_USING_SPI_FLASH'):
    src += ['drv_spiflash.c']

# add pwm driver code
if GetDepend('BSP_USING_PWM0') or GetDepend('BSP_USING_PWM1') or GetDepend('BSP_USING_PWM2') or GetDepend('BSP_USING_PWM3'):
    src += ['drv_pwm.c']

# add hwtimer driver code
if GetDepend('BSP_USING_HWTIMER0') or GetDepend('BSP_USING_HWTIMER1') or GetDepend('BSP_USING_HWTIMER2') or GetDepend('BSP_USING_HWTIMER3'):
    src += ['drv_hwtimer.c']

# add rtc driver code
if GetDepend(['BSP_USING_RTC']):
    src += ['drv_rtc.c']

# add pm driver code
if GetDepend(['BSP_USING_PM']):
    src += ['drv_pm.c']
    src += ['drv_lptim.c']

# add adc driver code
if GetDepend(['BSP_USING_ADC']):
    src += ['drv_adc.c']

CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
objs = objs + group

src   = []
cwd   = GetCurrentDir()
include_path = [cwd]

if GetDepend('BSP_USING_EXAMPLE_ADC_VOL'):
    src += ['bsp_driver_example/adc_vol_sample.c']

if GetDepend('BSP_USING_EXAMPLE_HWTIMER'):
    src += ['bsp_driver_example/hwtimer_sample.c']

if GetDepend('BSP_USING_EXAMPLE_I2C'):
    src += ['bsp_driver_example/i2c_sample.c']

if GetDepend('BSP_USING_EXAMPLE_LED_BLINK'):
    src += ['bsp_driver_example/led_blink_sample.c']

if GetDepend('BSP_USING_EXAMPLE_PIN_BEEP'):
    src += ['bsp_driver_example/pin_beep_sample.c']

if GetDepend('BSP_USING_EXAMPLE_PWM_LED'):
    src += ['bsp_driver_example/pwm_led_sample.c']

if GetDepend('BSP_USING_EXAMPLE_RTC'):
    src += ['bsp_driver_example/rtc_sample.c']

if GetDepend('BSP_USING_EXAMPLE_UART'):
    src += ['bsp_driver_example/uart_sample.c']

if GetDepend('BSP_USING_EXAMPLE_SPI'):
    src += ['bsp_driver_example/spi_sample.c']

if GetDepend('BSP_USING_EXAMPLE_PM'):
    src += ['bsp_driver_example/pm_sample.c']

group = DefineGroup('bsp-drivers-test-samples', src, depend = [''], CPPPATH = include_path)

objs = objs + group
Return('objs')